#pragma once
#include "ZuiLib.h"
#include "LRefObject.h"

namespace ZuiLib {

class LImageControl :public LRefObject<ZImageControl>
{
public:

	int setData(LuaFuncState& L)
	{
		if(L.arg(0).isString())
			pThis->SetData((uint8_t*)L.arg(0).toString(), L.arg(0).objLen());
		else if(L.arg(0).isUData())
			pThis->SetData((uint8_t*)L.arg(0).toPtr(), L.arg(0).objLen());
		return 0;
	}

	int setFile(LuaFuncState& L)
	{
		pThis->SetFile(L.arg(0).toString());
		return 0;
	}

	int setFileAsync(LuaFuncState& L)
	{
		pThis->SetFileAsync(L.arg(0).toString());
		return 0;
	}

	int setAutoSize(LuaFuncState& L)
	{
		pThis->SetAutoSize(L.arg(0).toBool());
		return 0;
	}

	int isLoaded(LuaFuncState& L)
	{
		return L.lreturn(pThis->IsLoaded());
	}

	BEGIN_MAP_FUNC(LImageControl)
	DECLARE_FUNC(setData),
	DECLARE_FUNC(setFile),
	DECLARE_FUNC(setFileAsync),
	DECLARE_FUNC(setAutoSize),
	DECLARE_FUNC(isLoaded),
	END_MAP_FUNC
};



class LNetImageControl :public LRefObject<ZNetImageControl>
{
public:

	int setUrl(LuaFuncState& L)
	{
		pThis->SetUrl(L.arg(0).toString());
		return 0;
	}

	int setErrorImage(LuaFuncState& L)
	{
		pThis->SetErrorImage(L.arg(0).toString());
		return 0;
	}

	int setLoadingImage(LuaFuncState& L)
	{
		pThis->SetLoadingImage(L.arg(0).toString());
		return 0;
	}

	BEGIN_MAP_FUNC(LNetImageControl)
	DECLARE_FUNC(setUrl),
	DECLARE_FUNC(setErrorImage),
	DECLARE_FUNC(setLoadingImage),
	END_MAP_FUNC
};

}//namespace
